package com.heiye.quiz.biz.domain.mapper;

import com.heiye.quiz.biz.domain.dataobject.QuizLikeDO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface QuizLikeDOMapper {
    int deleteByPrimaryKey(Long id);

    int insert(QuizLikeDO record);

    int insertSelective(QuizLikeDO record);

    QuizLikeDO selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(QuizLikeDO record);

    int updateByPrimaryKey(QuizLikeDO record);

    /**
     * 查询用户对问题是否点赞
     *
     * @param userId
     * @param quizId
     * @return
     */
    int selectCountByUserIdAndQuizId(@Param("userId") Long userId, @Param("quizId") Long quizId);

    /**
     * 根据用户 ID 查询用户点赞过的问题
     *
     * @param userId
     * @return
     */
    List<QuizLikeDO> selectByUserId(@Param("userId") Long userId);

    /**
     * 新增问题点赞记录，若已存在，则更新笔记点赞记录
     *
     * @param quizLikeDO
     * @return
     */
    int insertOrUpdate(QuizLikeDO quizLikeDO);

    /**
     * 取消点赞
     *
     * @param quizLikeDO
     * @return
     */
    int update2UnlikeByUserIdAndQuizId(QuizLikeDO quizLikeDO);

    /**
     * 批量插入或更新
     * @param quizLikeDOS
     * @return
     */
    int batchInsertOrUpdate(@Param("noteLikeDOS") List<QuizLikeDO> quizLikeDOS);
}